package com.xcdh.ittools.service.impl;

import com.api.ittools.entity.Tables;
import com.api.ittools.entity.TablesColumn;
import com.xcdh.ittools.mapper.metadata.oracle.OracleColumnMapper;
import com.xcdh.ittools.mapper.metadata.oracle.OracleTableMapper;
import com.xcdh.ittools.service.MataDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * OracleMataDataServiceImpl
 * Created by wjg on 2024/4/22.
 */
@Service("oracleMataDataService")
public class OracleMataDataServiceImpl implements MataDataService {
    @Autowired
    private OracleColumnMapper columnMapper ;
    @Autowired
    private OracleTableMapper tableMapper ;


    @Override
    public Tables getTable(String database , String tableName) {
        List<Tables> tables = tableMapper.queryTables(database, tableName);
        Tables build = Tables.builder().dataBaseName(database).tableName(tableName).build();
        List<TablesColumn> tableColumns = columnMapper.getTableColumns(build);
        Tables tables1 = tables.get(0);
        tables1.setColumns(tableColumns);
        return  tables1;
    }
}
